KISSY.use("node",function(S,Node){ 
$(".bui-tab-item").on("click",function(){
		$(".bui-tab-item").removeClass("bui-tab-item-selected");
		$(this).addClass("bui-tab-item-selected");
		var tp = $(this).attr("data-tp");
		location.href=("/?a=add&m=shop&c=content&ctp="+tp);
	});
$(".add").on("click",function(){
	location.href=("/?a=add&m=shop&c=content");
});
$(".list").on("click",function(){
	var ctp =$(this).attr("data-ctp");
	location.href=("/?a=list&m=shop&c=content&ctp="+(ctp?ctp:"content"));
});
$(".tags").on("click",function(){
	$(".tags").removeClass("badge-info");
	$(this).addClass("badge-info");
	$(".tag").val($(this).attr("data-tagname"));
	$(".tagid").val($(this).attr("data-tagid"));
}); 
$(".js-itemurl").on("mouseenter",function(){if(this.value=="请输入商品地址"){this.value=""}});
$(".js-load").on("click",function(){
	var url=$(".js-itemurl").val();
	var itemid = url.match(/(&|\?)id=[0-9]{11,}/g);
	var id=$(".id").val();
	if(!itemid){
		if(url.match(/[0-9]{11,}/g)){
			location.href=("/?a=add&m=shop&c=content&ctp=items&itemid="+url+"&id="+id);
		}else{
			alert("输入的链接有误，请输入商品页面地址重试！")
		}
	}else{
		itemid = itemid[0].substr(4);
		location.href=("/?a=add&m=shop&c=content&ctp=items&itemid="+itemid+"&id="+id);
	}
});
$(".js-img").on("click",function(){
	if($(".uImage").css("width")!="90px"){
		$(".uImage").css("width","90px");
		$(this).css("background-position","9px");
	}else{
		$(".uImage").css("width","590px");
		$(this).css("background-position","22px");
	}
});
$(".js-pic").on("click",function(){
	var src = $(this).attr("data-src");
	$(".js-coverpic").getDOMNode().src=src+"_80x80.jpg";
	$(".coverpic").val(src);
});
$(".js-upload").on("click",function(){
	$(".J_TCajaUploadImg").fire("click");
});
$("form").on("submit",function(){
	// alert("检查字段");
});
function isNumber( s ){ 
	var regu = "^[0-9]+$"; 
	var re = new RegExp(regu); 
	if (s.search(re) != -1) { 
	return true; 
	} else { 
	return false; 
	}
} 
GS.addListener('cajaupload',function(d){
		var response = KISSY.JSON.parse(d.content);
		if(response['success']){
			$("."+response["img"]+"pic").val(response['url']);
			$("."+response["img"]).empty();
			var str = "<img src='"+response['url']+"' />";
			$(str).appendTo("."+response["img"]);
		}else{
			alert("上传失败");
		}
	});
});